package win.smartown.app.base;

import android.os.Bundle;
import android.support.annotation.IdRes;
import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

/**
 * Created by smartown on 2017/3/19.
 * <br>
 * Description:
 */
public class BaseFragment extends Fragment {

    private View contentView;

    public void setContentView(@LayoutRes int layoutId) {
        contentView = LayoutInflater.from(getActivity()).inflate(layoutId, null);
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return contentView;
    }

    protected <T extends View> T findView(@IdRes int id) {
        return (T) contentView.findViewById(id);
    }

    protected SuperActivity getSuperActivity() {
        return (SuperActivity) getActivity();
    }

    protected BaseActivity getBaseActivity() {
        return (BaseActivity) getActivity();
    }

    protected LoadingActivity getLoadingActivity() {
        return (LoadingActivity) getActivity();
    }

}
